public class Categories {

	public String href { get; set; }
	
	public Categories(XmlStreamReader reader) {
		String tagName = 'categories';
		handleAttributes(reader, tagName);
        if (reader.hasNext()) {
			reader.next();
			while (reader.hasNext()) {
				if (reader.getEventType() == XmlTag.END_ELEMENT) {
					if (reader.getLocalName() == 'categories') {
						return;
					} 
				//} else if (reader.getEventType() == XmlTag.CHARACTERS) {
                //	if ( ! reader.isWhitespace()) { 
                //	}
            	} else if (reader.getEventType() == XmlTag.START_ELEMENT) { 
					tagName = reader.getLocalName(); 
					handleAttributes(reader, tagName);
            	}
               	reader.next(); 
			}
        }
	}
	
	public String ToAPP() {
		String out = '<categories';
		if (href != null) {
			out += 'href="' + href + '"';
		}
		out += ' />';
		return out;
	}
	
	private void handleAttributes(XmlStreamReader reader, String tagName) {
		for (integer i=0; i<reader.getAttributeCount(); i++) {
       		String name = reader.getAttributeLocalName(i);
       		String value = reader.getAttributeValueAt(i);
        	if (tagName == 'categories') {
        		if (name == 'href') {
        			href = value;
        		} 
        	}
        }
        
	}
	
}